﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Text;
using QuanLyBongDa.HeThongGiaoDien;
using QuanLyBongDa.HeThongLuuTru;
using QuanLyBongDa.HeThongXuLy;

namespace QuanLyBongDa.HeThongLuuTru
{
    class LichThiDau
    {
        public static bool ThemLichThiDau(LichThiDauDTO ltd)
        {
            try
            {
                string sql = "insert into LICHTHIDAU(VongDau, Doi1, Doi2, TenSan, Ngay, Gio) values (" + ltd.VongDau + ",'" + ltd.Doi1 + "','" + ltd.Doi2 + "', '" + ltd.TenSan + "', '" + ltd.Ngay + "', '" + ltd.Gio + "')";
                DataAccess.ExecNonQuery(sql);
                return true;

            }
            catch (Exception)
            {
                //MessageBox.Show(ex.ToString());
                return false;
            }
        }
        public static DataTable LapLichThiDau()
        {
            string sql = "SELECT* FROM LICHTHIDAU";
            return DataAccess.ExecQuery(sql);
        }

        public static bool XoaLichThiDau(LichThiDauDTO ltd)
        {
            try
            {
                string sql = "Delete from LICHTHIDAU where MaVongDau = " + ltd.MaVongDau;
                DataAccess.ExecNonQuery(sql);
                return true;
            }
            catch (Exception)
            {
                return false;
            }
        }
        public static bool SuaLichThiDau(LichThiDauDTO ltd)
        {
            try
            {
                string sql = "Update LICHTHIDAU set VongDau = " + ltd.VongDau + "',Doi1 = '" + ltd.Doi1 + "',Doi2 = '" + ltd.Doi2 + "',TenSan = '" + ltd.TenSan + "',Ngay = '" + ltd.Ngay + "',Gio = '" + ltd.Gio + "'where MaVongDau=" + ltd.MaVongDau;
                DataAccess.ExecNonQuery(sql);
                return true;
            }
            catch (Exception)
            {
                return false;
            }
        }
    }
}
